import React, { forwardRef, useState, useImperativeHandle } from 'react'

function Child (props, ref) {
  const [count, setCount] = useState(100)

  // useImperativeHandle(ref, () => {
  //   return {
  //     setCount,
  //     name: '哈哈'
  //   }
  // })

  useImperativeHandle(ref, () => ({
    setCount,
    name: 'ww'
  }))
  return (
    <div>
      Child
      <p>count is {count}</p>
    </div>
  )
}

export default forwardRef(Child)
